#include "windowstft.h"
#include "ui_windowstft.h"
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlabel.h>

WindowSTFT::WindowSTFT(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::WindowSTFT)
{
    ui->setupUi(this);
}

WindowSTFT::WindowSTFT(std::vector<std::vector<double> > &matrix ,
                       const double duration, const double LowFreq, const double HighFreq, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::WindowSTFT)
{
    ui->setupUi(this);

    plot = new Plot(matrix ,duration, LowFreq, HighFreq, this);

    setCentralWidget(plot);

    QToolBar *toolBar = new QToolBar( this );

    QComboBox *rasterBox = new QComboBox( toolBar );
    rasterBox->addItem( "Wikipedia" );

    toolBar->addWidget( new QLabel( "Data ", toolBar ) );
    toolBar->addWidget( rasterBox );
    toolBar->addSeparator();

    QComboBox *modeBox = new QComboBox( toolBar );
    modeBox->addItem( "Nearest Neighbour" );
    modeBox->addItem( "Bilinear Interpolation" );

    toolBar->addWidget( new QLabel( "Resampling ", toolBar ) );
    toolBar->addWidget( modeBox );

    toolBar->addSeparator();

    QToolButton *btnExport = new QToolButton( toolBar );
    btnExport->setText( "Export" );
    btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    toolBar->addWidget( btnExport );

    addToolBar( toolBar );

    connect( modeBox, SIGNAL( activated( int ) ), plot, SLOT( setResampleMode( int ) ) );
    connect( btnExport, SIGNAL( clicked() ), plot, SLOT( exportPlot() ) );
}

WindowSTFT::~WindowSTFT()
{
    delete ui;
    delete plot;
}
